package net.jgrm.order.dto;

import java.time.LocalDateTime;

/**
 * 订单查询参数类
 * 支持多种查询条件，包括手机号、姓名、订单状态、时间范围等
 */
public class QueryOrderParams {
    // 手机号相关查询条件
    private String phonePrefix;
    private String fullPhone;
    private String phoneSuffix;

    // 其他查询条件
    private String receiverName;     // 收货人姓名
    private Integer orderStatus;     // 订单状态
    private String orderNo;          // 订单号
    private Long userId;             // 用户ID
    private LocalDateTime startTime; // 创建时间起始
    private LocalDateTime endTime;   // 创建时间结束

    // 分页参数
    private Integer pageNum = 1;     // 页码，默认第1页
    private Integer pageSize = 10;   // 每页大小，默认10条

    public void setPhonePrefix(String phonePrefix) {
        this.phonePrefix = phonePrefix;
    }

    public String getPhonePrefix() {
        return phonePrefix;
    }

    public void setPhoneSuffix(String phoneSuffix) {
        this.phoneSuffix = phoneSuffix;
    }

    public String getPhoneSuffix() {
        return phoneSuffix;
    }

    public void setFullPhone(String fullPhone) {
        this.fullPhone = fullPhone;
    }

    public String getFullPhone() {
        return fullPhone;
    }

    public String getReceiverName() {
        return receiverName;
    }

    public void setReceiverName(String receiverName) {
        this.receiverName = receiverName;
    }

    public Integer getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    /**
     * 判断是否包含手机号查询条件
     *
     * @return true-包含手机号查询条件，false-不包含
     */
    public boolean hasPhoneQuery() {
        return fullPhone != null || phonePrefix != null || phoneSuffix != null;
    }

    /**
     * 获取手机号查询类型
     *
     * @return 1-完整手机号，2-前缀，3-后缀，0-无手机号查询
     */
    public int getPhoneQueryType() {
        if (fullPhone != null) {
            return 1; // 完整手机号
        } else if (phonePrefix != null) {
            return 2; // 前缀
        } else if (phoneSuffix != null) {
            return 3; // 后缀
        }
        return 0; // 无手机号查询
    }

    /**
     * 获取手机号查询值
     *
     * @return 手机号查询值
     */
    public String getPhoneQueryValue() {
        if (fullPhone != null) {
            return fullPhone;
        } else if (phonePrefix != null) {
            return phonePrefix;
        } else if (phoneSuffix != null) {
            return phoneSuffix;
        }
        return null;
    }
}
